﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE.Web.Betfair.Interface.Entities;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;

namespace BE.Web.Betfair.Interface.Requests
{
    /// <summary>
    /// Request for reading the prices of a market
    /// </summary>
    public sealed class MarketPriceRequest : SessionBasedRequest<ReadOnlyCollection<BetMarketPrice>>
    {

        /// <summary>
        /// Objects the invariant.
        /// </summary>
        [ContractInvariantMethod]
        void ObjectInvariant()
        {
            Contract.Invariant(this.MarketId > 0);
        }
        /// <summary>
        /// Id of the market for which the prices should be resolved
        /// </summary>
        public int MarketId { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="MarketPriceRequest"/> class.
        /// </summary>
        /// <param name="marketId">The market id.</param>
        /// <param name="session">The session.</param>
        /// <param name="completedAction">The completed action.</param>
        public MarketPriceRequest(int marketId, Session session, Action<ReadOnlyCollection<BetMarketPrice>> completedAction) :
            base(session, completedAction)

        {
            Contract.Requires<ArgumentNullException>(session != null);
            Contract.Requires<ArgumentOutOfRangeException>(marketId > 0);
            Contract.Ensures(this.MarketId > 0);

            this.MarketId = marketId;
        }
    }
}
